﻿(function($){
    $(window).load(function(){
        $(".tab-content").mCustomScrollbar();
    });
})(jQuery);
function changeVid(num){
    // var src = $("video").attr("src");
    //var index = $(".bee-panel-item .bee-item").index($(".item-"+num));
    // //alert(index);
    // alert(num);
    if ($(".bee-panel-item .item-"+num).next(".bee-item").length >0){
        var newSrc = $(".bee-panel-item .item-"+num).next().find("img").attr("data-src");
        $("video").attr("src",newSrc);
        return num;
    }else{
        //alert("Done");
        num=0;
        var newSrc = $(".bee-panel-item .item-"+num).find("img").attr("data-src");
        $("video").attr("src",newSrc);
        return num=-1;
    }
    
}


$(document).ready(function () {
    // $(".tabs").mCustomScrollbar();
    var num =0;
    $("video").bind("ended", function() {
        var note = changeVid(num);
        if (note==-1){
            num=0;
        }else{
            num++;
        }
        //alert( note +" - "+ num);
    });
    var w = $(window).width();
    var h = $(window).height();
    $(".container-homepage, .bee-panel-1").height(h);
    $(".bee-panel-1").width(0.8 * w);
    $(".bee-panel-2").width(0.2 * w - 50);
    $(".bee-panel-item").height(h/4-5);
    $(".st-caption").width(w-$(".st-video").width()-75);
    $(".tt-menu").click(function () {
        $("header").toggleClass("show");
        $("header.show").animate({
            left: "+=200"
        });
        $("header:not(.show)").animate({
            left: "-=200"
        });
        return false;
    });

    $(".tt-register, .close-register").click(function () {
        $("#container-register").toggleClass("register-show");
        if ($("#container-register").hasClass("register-show")) {
            $("#container-register").animate({
                top: "+=100%"
            });
        } else {
            $("#container-register").animate({
                top: "-=100%"
            });
        }
    });

    //Click to view image
    $("img.img-mask").click(function () {
        var src = $(this).attr("src");
        $("div.img-mask-area .container").append("<img src='" + src + "'/>");
        $("div.img-mask-area").fadeIn();
    });
    $("a.close-div-image").click(function () {
        $("div.img-mask-area .container img").remove();
        $("div.img-mask-area").fadeOut();
        return false;
    });
    $("select").selectpicker({ style: 'btn-hg btn-primary', menuStyle: 'dropdown-inverse' });
    $("select#changePage").change(function(){
        $("select#changePage option:selected").each(function(){
            $("span.titlePage").html($(this).text());
            var item = $(this).val();
            if (item==0){
                $("div.infoPage").css("display","block");

                $("div.awardPoint").css("display","none");
                $("div.exchangeHistory").css("display","none");
            }else if (item==1){
                $("div.infoPage").css("display","none");
                $("div.awardPoint").css("display","block");
                $("div.exchangeHistory").css("display","none");
            }else{
                $("div.infoPage").css("display","none");
                $("div.awardPoint").css("display","none");
                $("div.exchangeHistory").css("display","block");
            }
        });
    });
    
    $("a.btnViewSubcribe").click(function(){
        var hSub = h-250;
        $(".subcribe").animate({
            height: "+="+hSub

        });
        $(".btnHide").css("display","block");
          $(".btnViewSubcribe").css("display","none");
        $(".subcribe img").addClass("margin2");
         $(".subcribe img.hided").css("display","block");
        return false;
    });
    $("a.btnHide").click(function(){
        var hSub = h-250;
        $(".subcribe").animate({
            height: "-="+hSub

        });
        $(".btnHide").css("display","none");
         $(".btnViewSubcribe").css("display","block");
        $(".subcribe img").removeClass("margin2");
         $(".subcribe img.hided").css("display","none");
        return false;
    });
    $(".btn-more-info-product").click(function(){
        $("div.more-info-product").css("display","none");
        $(this).parent().parent().parent().find(".more-info-product").css("display","block");
    });
    $(".off-info-product").click(function(){
        $("div.more-info-product").css("display","none");
        return false;
    });
});